
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
request.setAttribute("decorator", "none");
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%>

<%-- 导入面包屑 --%>
<jsp:include page="../common/nav.jsp"></jsp:include>

<div class="wrapper wrapper-content animated fadeInRight">

    <%-- 导入提示信息框 --%>
    <c:if test="${hint!=null&&hint!=''}">
   		<jsp:include page="../common/alert/alert.jsp">
   			<jsp:param value="${hint}" name="alertType"/>
   			<jsp:param value="${alertMessage}" name="alertMessage"/>
   		</jsp:include>
    </c:if>
	
	<%-- 导入查询框 --%>
	<jsp:include page="search/prodWipTaskSearch.jsp"></jsp:include>
	
	<div class="row">
		<div class="col-lg-12">
			<div class="ibox ">
		        <div class="ibox-title">
		            <h4>生产任务列表</h4>
		            <div class="ibox-tools">
		                <button id="addButton" class="btn btn-success btn-sm" type="button"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">新增生产任务</span></button>
		                <button id="searchButton" class="btn btn-default btn-sm btn-notcontrol" type="button"><i class="fa fa-search"></i>&nbsp;&nbsp;展开查询</button>
		            	<button id="exportListButton" class="btn btn-sm btn-notcontrol" type="button"><i class="fa fa-download"></i>&nbsp;&nbsp;导出表格</button>
		            </div>
		        </div>
				<div class="ibox-content border-bottom" style="padding-bottom: 0px;">
					<div class="table-responsive">
						<table class="table table-striped table-hover table-bordered border-top">
							<thead>
								<tr>
									<%-- 
									<th></th>
									--%>
									<th width="5%">序号</th>
									<th>任务编码</th>
									<th>任务名称</th>
									<th>生产物料</th>
									<th>生产数量</th>
									<th>开工日期</th>
									<th>完工日期</th>
									<th width="7%">任务状态</th>
									<th>制单人</th>
									<th>创建时间</th>
									<th width="5%">数据状态</th>
									<th width="8%">审批状态</th>
									<th width="10%">操作</th>
								</tr>
							</thead>
							<tbody>
							
							    <c:forEach items="${requestScope.prodWipTaskList}" var="data" varStatus="status">
								<tr>
									<%-- 
									<td><input type="checkbox" class="i-checks"
										name="input[]"></td>
									--%>	
									<td>${status.count}</td>
									<td>${data.taskCode}</td>
									<td>${data.taskName}</td>
									<td>${requestScope.materialMap[data.materialCode]}</td>
									<td>${data.quantity}</td>
									<td><fmt:formatDate value="${data.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
									<td><fmt:formatDate value="${data.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
									<td>${requestScope.taskStatusMap[data.taskStatus]}</td>
									<td>${data.staffName}【${data.departmentName}】</td>
									<td><fmt:formatDate value="${data.createdDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
									<td>
										<c:choose>
										   <c:when test="${data.status=='NEW'}">
										       <span class="label label-primary">${requestScope.statusMap[data.status]}</span>
										   </c:when>
										   <c:when test="${data.status=='CONFIRM'}">
										       <span class="label label-success">${requestScope.statusMap[data.status]}</span>
										   </c:when>
										   <c:otherwise>
										       <span class="label label-danger">${requestScope.statusMap[data.status]}</span>
										   </c:otherwise>
										</c:choose>
									</td>
									<td>
										<c:choose>
										   <c:when test="${data.approveStatus=='UNSUBMIT'}">
										       <span class="label">${requestScope.approveStatusMap[data.approveStatus]}</span>
										   </c:when>
										   <c:when test="${data.approveStatus=='SUBMIT'}">
										       <span class="label label-primary">${requestScope.approveStatusMap[data.approveStatus]}</span>
										   </c:when>
										   <c:when test="${data.approveStatus=='APPROVE'}">
										       <span class="label label-success">${requestScope.approveStatusMap[data.approveStatus]}</span>
										   </c:when>
										   <c:when test="${data.approveStatus=='REJECT'}">
										       <span class="label label-warning">${requestScope.approveStatusMap[data.approveStatus]}</span>
										   </c:when>
										</c:choose>
										
									<c:if test="${requestScope.workflowFlag=='Y'}">
										<span class="label label-default" style="cursor: pointer;" onclick="getWorkflowRecordListModal('WIP','${data.taskCode}')"><i class="fa fa-info-circle" style="color: black;"></i></span>
									</c:if>
									</td>
									<td>
										<div class="btn-group">
											<button class="btn-white btn btn-xs btn-notcontrol" onclick="editData('${data.taskCode}')"><i class="fa fa-edit"></i>&nbsp;编辑</button>&nbsp;
											<c:if test="${data.approveStatus!='APPROVE'&&data.approveStatus!='SUBMIT'}">
												<button class="btn-white btn btn-xs" onclick="deleteData(${data.taskId},'${data.taskCode}','${data.status}')"><i class="fa fa-trash"></i>&nbsp;删除</button>
											</c:if>
										</div>
									</td>
								</tr>
								</c:forEach>
								
							</tbody>
							<tfoot>
							    <%-- 导入页码 --%>
								<jsp:include page="../common/pages.jsp"></jsp:include>
							</tfoot>
						</table>
					</div>

				</div>
			</div>
		</div>
		
	</div>
</div>

<!-- listPage -->
<script src="js/listPage.js"></script>

<!-- workflow -->
<script src="js/workflow.js"></script>
<div id="approveWorkflowModal"></div>

<script>
	$(document).ready(function() {
		/*
		$('.i-checks').iCheck({
			checkboxClass : 'icheckbox_square-green',
			radioClass : 'iradio_square-green',
		});
		*/
		$("#addButton").click(function(){
		    window.location.href="web/prodWipTask/getProdWipTask";
		});
		
	});
	
	function editData(code){
		window.location.href="web/prodWipTask/getProdWipTask?taskCode="+code;
	}
	
	function deleteData(id, code, status) {
		redragonJS.confirm("确认删除数据？", function(){
			window.location.href="web/prodWipTask/deleteProdWipTask?taskId="+id+"&taskCode="+code+"&status="+status;
		});
	}
</script>       